মেথড ওভারলোডিং ব্যবহার করে জাভা প্রোগ্রাম

 Package Method-Overloading ;

class Student {

int roll ;

String name ;

float mark ;

Student(int r, String n, float m){

roll = r;

name= n;

mark= m;

}

Student(Student s){

roll=s.roll;

name=s.name;

mark=s.mark;

}

void Display(){

System.out.println(“Roll is: “+roll);

System.out.println(“Name is: “+name);

System.out.println(“Mark is: “+mark);

}
}

public class CopyConstructor{

public static void main (String [ ]args){

Student s1 = new Student (934673,”Khalid”, 85.25f);

S1.Display( );

Student s2 = new Student (s1);

s2.Display( );

}

}

Next Post Previous Post
No Comment
Add Comment
comment url